home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 1 / QRZ Ham Radio Callsign Database - December 1993.iso / ucsd / packet / tcpip / amiga / asrc29k.lha / ax25.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-08  |  6.4 KB  |  189 lines

  1. #ifndef    NULLAXR
  2.  
  3. #include "global.h"
  4.  
  5. /* AX.25 datagram (address) sub-layer definitions */
  6.  
  7. #define    NHASH        17    /* Number of hash chains in AX.25 routing
  8.                  * tables, LAPB control blocks and link
  9.                  * status tables
  10.                  */
  11. #define    MAXDIGIS    7    /* Maximum number of digipeaters */
  12. #define    ALEN        6    /* Number of chars in callsign field */
  13. #define    AXALEN        7    /* Total AX.25 address length, including SSID */
  14. #define    AXBUF        10    /* Buffer size for maximum-length ascii call */
  15.  
  16. /* Bits within SSID field of AX.25 address */
  17. #define    SSID        0x1e    /* Sub station ID */
  18. #define    REPEATED    0x80    /* Has-been-repeated bit in repeater field */
  19. #define    E        0x01    /* Address extension bit */
  20. #define    C        0x80    /* Command/response designation */
  21. /* Our AX.25 address */
  22. extern char Mycall[AXALEN];
  23.  
  24. /* AX.25 broadcast address: "QST   -0" in shifted ASCII */
  25. extern char Ax25_bdcst[AXALEN];
  26.  
  27. extern int Digipeat;
  28. extern int Ax25mbox;
  29.  
  30. /* Internal representation of an AX.25 header */
  31. struct ax25 {
  32.     char dest[AXALEN];        /* Destination address */
  33.     char source[AXALEN];        /* Source address */
  34.     char digis[MAXDIGIS][AXALEN];    /* Digi string */
  35.     int ndigis;            /* Number of digipeaters */
  36.     int nextdigi;            /* Index to next digi in chain */
  37.     int cmdrsp;            /* Command/response */
  38. };
  39.  
  40. /* C-bit stuff */
  41. #define    LAPB_UNKNOWN        0
  42. #define    LAPB_COMMAND        1
  43. #define    LAPB_RESPONSE        2
  44.  
  45. /* AX.25 routing table entry */
  46. struct ax_route {
  47.     struct ax_route *prev;        /* Linked list pointers */
  48.     struct ax_route *next;
  49.     char target[AXALEN];
  50.     char digis[MAXDIGIS][AXALEN];
  51.     int ndigis;
  52.     char type;
  53. #define    AX_LOCAL    1        /* Set by local ax25 route command */
  54. #define    AX_AUTO        2        /* Set by incoming packet */
  55.     char mode;
  56. #define    AX_DEFMODE    0        /* Use default interface mode */
  57. #define    AX_VC_MODE    1        /* Try to use Virtual Circuit */
  58. #define    AX_DATMODE    2        /* Try to use Datagrams Only  */
  59. };
  60. #define NULLAXR    ((struct ax_route *)0)
  61.  
  62. extern struct ax_route *Ax_routes[NHASH];
  63. extern struct ax_route Ax_default;
  64.  
  65. /* AX.25 Level 3 Protocol IDs (PIDs) */
  66. #define PID_X25        0x01    /* CCITT X.25 PLP */
  67. #define    PID_SEGMENT    0x08    /* Segmentation fragment */
  68. #define PID_TEXNET    0xc3    /* TEXNET datagram protocol */
  69. #define    PID_LQ        0xc4    /* Link quality protocol */
  70. #define    PID_APPLETALK    0xca    /* Appletalk */
  71. #define    PID_APPLEARP    0xcb    /* Appletalk ARP */
  72. #define    PID_IP        0xcc    /* ARPA Internet Protocol */
  73. #define    PID_ARP        0xcd    /* ARPA Address Resolution Protocol */
  74. #define    PID_NETROM    0xcf    /* NET/ROM */
  75. #define    PID_NO_L3    0xf0    /* No level 3 protocol */
  76.  
  77. #define    SEG_FIRST    0x80    /* First segment of a sequence */
  78. #define    SEG_REM        0x7f    /* Mask for # segments remaining */
  79.  
  80. #define    AX_EOL        "\r"    /* AX.25 end-of-line convention */
  81.  
  82. /* Link quality report packet header, internal format */
  83. struct lqhdr {
  84.     int16 version;        /* Version number of protocol */
  85. #define    LINKVERS    1
  86.     int32    ip_addr;    /* Sending station's IP address */
  87. };
  88. #define    LQHDR    6
  89. /* Link quality entry, internal format */
  90. struct lqentry {
  91.     char addr[AXALEN];    /* Address of heard station */
  92.     int32 count;        /* Count of packets heard from that station */
  93. };
  94. #define    LQENTRY    11
  95.  
  96. /* Link quality database record format
  97.  * Currently used only by AX.25 interfaces
  98.  */
  99. struct lq {
  100.     struct lq *next;
  101.     char addr[AXALEN];    /* Hardware address of station heard */
  102.     struct iface *iface;    /* Interface address was heard on */
  103.     int32 time;        /* Time station was last heard */
  104.     int32 currxcnt;    /* Current # of packets heard from this station */
  105. };
  106. #define    NULLLQ    (struct lq *)0
  107.  
  108. extern struct lq *Lq;    /* Link quality record headers */
  109.  
  110. /* Structure used to keep track of monitored destination addresses */
  111. struct ld {
  112.     struct ld *next;    /* Linked list pointers */
  113.     char addr[AXALEN];/* Hardware address of destination overheard */
  114.     struct iface *iface;    /* Interface address was heard on */
  115.     int32 time;        /* Time station was last mentioned */
  116.     int32 currxcnt;    /* Current # of packets destined to this station */
  117. };
  118. #define    NULLLD    (struct ld *)0
  119.  
  120. extern struct ld *Ld;    /* Destination address record headers */
  121.  
  122. /* Codes for the open_ax25 call */
  123. #define    AX_PASSIVE    0
  124. #define    AX_ACTIVE    1
  125. #define    AX_SERVER    2    /* Passive, clone on opening */
  126.  
  127. #define    AXHEARD_PASS    0    /* Log both src and dest callsigns */
  128. #define    AXHEARD_NOSRC    1    /* do not log source callsign */
  129. #define    AXHEARD_NODST    2    /* do not log destination callsign */
  130. #define    AXHEARD_NONE    3    /* do not log any callsign */
  131.  
  132. /* In ax25.c: */
  133. struct ax_route *ax_add __ARGS((char *,int,char digis[][AXALEN],int));
  134. int ax_drop __ARGS((char *));
  135. struct ax_route *ax_lookup __ARGS((char *));
  136. void ax_recv __ARGS((struct iface *,struct mbuf *));
  137. int ax_send __ARGS((struct mbuf *bp,struct iface *iface,int32 gateway,int prec,
  138.     int del,int tput,int rel));
  139. int ax_output __ARGS((struct iface *iface,char *dest,char *source,int16 pid,
  140.     struct mbuf *data));
  141. void axarp __ARGS((void));
  142. int sendframe __ARGS((struct ax25_cb *axp,int cmdrsp,int ctl,struct mbuf *data));
  143.  
  144. /* In ax25cmd.c: */
  145. void st_ax25 __ARGS((struct ax25_cb *axp));
  146.  
  147. /* In axhdr.c: */
  148. struct mbuf *htonax25 __ARGS((struct ax25 *hdr,struct mbuf *data));
  149. int ntohax25 __ARGS((struct ax25 *hdr,struct mbuf **bpp));
  150.  
  151. /* In axlink.c: */
  152. void getlqentry __ARGS((struct lqentry *ep,struct mbuf **bpp));
  153. void getlqhdr __ARGS((struct lqhdr *hp,struct mbuf **bpp));
  154. void logsrc __ARGS((struct iface *iface,char *addr));
  155. void logdest __ARGS((struct iface *iface,char *addr));
  156. char *putlqentry __ARGS((char *cp,char *addr,int32 count));
  157. char *putlqhdr __ARGS((char *cp,int16 version,int32 ip_addr));
  158.  
  159. /* In ax25user.c: */
  160. int ax25val __ARGS((struct ax25_cb *axp));
  161. int disc_ax25 __ARGS((struct ax25_cb *axp));
  162. int kick_ax25 __ARGS((struct ax25_cb *axp));
  163. struct ax25_cb *open_ax25 __ARGS((struct iface *,char *,char *,
  164.     int,int16,
  165.     void (*) __ARGS((struct ax25_cb *,int)),
  166.     void (*) __ARGS((struct ax25_cb *,int)),
  167.     void (*) __ARGS((struct ax25_cb *,int,int)),
  168.     int user));
  169. struct mbuf *recv_ax25 __ARGS((struct ax25_cb *axp,int16 cnt));
  170. int reset_ax25 __ARGS((struct ax25_cb *axp));
  171. int send_ax25 __ARGS((struct ax25_cb *axp,struct mbuf *bp,int pid));
  172.  
  173. /* In ax25subr.c: */
  174. int addreq __ARGS((char *a,char *b));
  175. int16 ax25hash __ARGS((char *s));
  176. struct ax25_cb *cr_ax25 __ARGS((char *addr));
  177. void del_ax25 __ARGS((struct ax25_cb *axp));
  178. struct ax25_cb *find_ax25 __ARGS((char *));
  179. char *pax25 __ARGS((char *e,char *addr));
  180. int setcall __ARGS((char *out,char *call));
  181.  
  182. /* In socket.c: */
  183. void beac_input __ARGS((struct iface *iface,char *src,struct mbuf *bp));
  184. void s_arcall __ARGS((struct ax25_cb *axp,int cnt));
  185. void s_ascall __ARGS((struct ax25_cb *axp,int old,int new));
  186. void s_atcall __ARGS((struct ax25_cb *axp,int cnt));
  187.  
  188. #endif    /* NULLAXADDR */
  189.